|
|
|
|
|
|
|
Finally, add the Private Sub LoadGraphData to the class. This is the code that moves the data from the Recordset into the graph control (see Listing 11.19). |
|
|
|
|
|
|
|
|
Listing 11.19. Coding the LoadGraphData method. |
|
|
|
|
|
|
|
|
Private Sub LoadGraphData()
'
' fill graph with data
'
On Error GoTo LocalErr
'
rs.MoveFirst
For lngLoop = 1 To lngNumPoints
frmGraph.Graph1.GraphData = rs.Fields(strFieldPoint)
rs.MoveNext
Next
'
Exit Sub
'
LocalErr:
Err.Raise vbObjectError + 3, App.EXEName, "Error loading graph data"
'
End Sub |
|
|
|
|
|
|
|
|
That's all there is to it. You now have a reusable data graphing OLE Server. All you need to do now is save the project and compile the DLL. You can do this by selecting File | Make prjDataGraph.DLL from the main menu. In the next section, you test this library with a simple example. |
|
|
|
|
|
|
|
|
Testing the Graph OLE Server |
|
|
|
|
|
|
|
|
You need to build a short program to test your new library. Suppose you have just been told that the marketing department needs a tool to display the year-to-date book sales by sales representative. The data already exists in a database, but there is no easy way to turn that data into a visual display that upper-level management can access on a regular basis. You have been asked to quickly put together a graphing front-end for the sales data. |
|
|
|
|
|
|
|
|
In order to complete the job, you need to initialize a copy of the DataGraph object; set the DatabaseName and SQLSelect properties; set the GraphType, GraphField, and GraphTitle properties; and then execute the ShowGraph method. From there, users can select various graph styles and, if they wish, save the graph to disk, send it to the printer, or copy it to the Clipboard to paste in other documents. |
|
|
|
|
|